﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace DataModels.Models
{
    [Serializable]
    public partial class LDForm : MTUHAReportBase
    {
        private Nullable<int> _C_1;
        public Nullable<int> C_1
        {
            get { return _C_1; }
            set
            {
                _C_1 = value;
                OnPropertyChanged("C_1");
            }
        }

        private Nullable<int> _C_5;
        public Nullable<int> C_5
        {
            get { return _C_5; }
            set
            {
                _C_5 = value;
                OnPropertyChanged("C_5");
            }
        }

        private Nullable<int> _C_12;
        public Nullable<int> C_12
        {
            get { return _C_12; }
            set
            {
                _C_12 = value;
                OnPropertyChanged("C_12");
            }
        }

        private Nullable<int> _C_13;
        public Nullable<int> C_13
        {
            get { return _C_13; }
            set
            {
                _C_13 = value;
                OnPropertyChanged("C_13");
            }
        }

        private Nullable<int> _C_14;
        public Nullable<int> C_14
        {
            get { return _C_14; }
            set
            {
                _C_14 = value;
                OnPropertyChanged("C_14");
            }
        }

        [ForeignKey("LDForm_TaarifaYaWaliojifungua")]
        public Nullable<int> TaarifaYaWaliojifungua_2id { get; set; }
        public virtual LDForm_TaarifaYaWaliojifungua LDForm_TaarifaYaWaliojifungua { get; set; }

        [ForeignKey("LDForm_NjiaYaKujifungua")]
        public Nullable<int> NjiaYaKujifungua_3id { get; set; }
        public virtual LDForm_NjiaYaKujifungua LDForm_NjiaYaKujifungua { get; set; }

        [ForeignKey("LDForm_MatatizoKablaYaKujifungua")]
        public Nullable<int> MatatizoKablaYaKujifungua_4id { get; set; }
        public virtual LDForm_MatatizoKablaYaKujifungua LDForm_MatatizoKablaYaKujifungua { get; set; }

        [ForeignKey("LDForm_MatatizoBaadaYaKujifungua")]
        public Nullable<int> MatatizoBaadaYaKujifungua_6id { get; set; }
        public virtual LDForm_MatatizoBaadaYaKujifungua LDForm_MatatizoBaadaYaKujifungua { get; set; }

        [ForeignKey("LDForm_EmOC")]
        public Nullable<int> EmOC_7id { get; set; }
        public virtual LDForm_EmOC LDForm_EmOC { get; set; }

        [ForeignKey("LDForm_PMTCT")]
        public Nullable<int> PMTCT_8id { get; set; }
        public virtual LDForm_PMTCT LDForm_PMTCT { get; set; }

        [ForeignKey("LDForm_WatotoWaliozaliwaMmoja")]
        public Nullable<int> WatotoWaliozaliwaMmoja_9id { get; set; }
        public virtual LDForm_WatotoWaliozaliwaMmoja LDForm_WatotoWaliozaliwaMmoja { get; set; }

        [ForeignKey("LDForm_WatotoWaliozaliwaMapacha")]
        public Nullable<int> WatotoWaliozaliwaMapacha_10id { get; set; }
        public virtual LDForm_WatotoWaliozaliwaMapacha LDForm_WatotoWaliozaliwaMapacha { get; set; }

        [ForeignKey("LDForm_WatotoWaliosaidiwaKupumua")]
        public Nullable<int> WatotoWaliosaidiwaKupumua_11id { get; set; }
        public virtual LDForm_WatotoWaliosaidiwaKupumua LDForm_WatotoWaliosaidiwaKupumua { get; set; }

        public static LDForm Deserialize(string serializedObject)
        {
            // Remove any namespace attribute.
            string xmlnsPattern = "\\s+xmlns\\s*(:\\w)?\\s*=\\s*\\\"(?<url>[^\\\"]*)\\\"";
            serializedObject = Regex.Replace(serializedObject, xmlnsPattern, "");

            var deserializer = new System.Xml.Serialization.XmlSerializer(typeof(LDForm));
            var reader = new System.IO.StringReader(serializedObject);
            using (var xmlReader = System.Xml.XmlReader.Create(reader))
            {
                if (deserializer.CanDeserialize(xmlReader))
                {
                    var e = deserializer.Deserialize(xmlReader) as LDForm;
                    return e;
                }
                else return null;
            }
        }
    }
}
